/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MaterialPack;

import Supporter.ImageSupporter;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author Van persie
 */

public class InfoBar extends MaterialObject {
    private int ratio;    // tinh bang %
    int colR,colG,colB;
    int side;
    public static final int VERTICAL = 1;
    public static final int HORIZON = 0;
    public InfoBar(String path,int _side, int val, int x,int y, int wid,int hei)
    {
        side = _side;
        ratio = val;
        super.GetGraphicsInfo(x, y, wid, hei);
        //super.LoadImage(path);
        //background = ImageSupporter.transparent(background);
        colR = 0;
        colR = 0;
        colR = 0;
    }
    public void SetColor(int r,int g, int b)
    {
        colR = r;
        colG = g;
        colB = b;
    }
    public void paint(Graphics g)
    {
        int color = g.getColor();
        g.setColor(colR, colG, colB);
        
        if(side == HORIZON)
            g.fillRect(getxPos(), getyPos(), (getWidth())*getRatio()/100, getHeight());
        else 
            g.fillRect(getxPos(), getyPos(), (getWidth()), (getHeight())*getRatio()/100);
        //g.drawImage(background, xPos, yPos,Graphics.TOP|Graphics.LEFT);
        g.setColor(color);
        g.drawRect(getxPos(), getyPos(), getWidth(), getHeight());
    }

    /**
     * @return the ratio
     */
    public int getRatio() {
        return ratio;
    }

    /**
     * @param ratio the ratio to set
     */
    public void setRatio(int ratio) {
        this.ratio = ratio;
    }
}
